//获取省市区
import w_address from "./W_address.js"
export const getpca = {
  data() {
    return {
    }
  },
  methods: {
    findcity(item) {
        return item.level == this.level;
    },
      //根据aname获取名字
    getAddressName(item) {
        return item.aname
    },
    selectProvince(items){
      items = String(items);
      let sheng = items.substring(0,2);
      console.log(this.provincelist,items)
      this.form.province = this.selectdata(items,this.provincelist);
      this.citylist = w_address.filter(function(item){
        return (item.level == 2 && item.sheng == sheng)
      })
    },
    selectcity(items){
      items = String(items);
      let sheng = items.substring(0,2);
      let di = items.substring(2,4);
      this.form.city = this.selectdata(items,this.citylist);
      this.arealist = w_address.filter(function(item){
        return (item.level == 3 && item.sheng == sheng && item.di == di)
      })
    },
    selectrase(items){
      this.form.area = this.selectdata(items,this.arealist);
    },
    //获取name
    selectdata(ites,list){
      for(let i = 0;i<list.length;i++){
        if(ites == list[i].code){
          return list[i].name
        }
      }
    },
  }
}